package com.xuxin.baby.adapter;

import android.widget.CheckBox;
import android.widget.ImageView;

import com.blankj.utilcode.util.LogUtils;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.xuxin.baby.R;
import com.xuxin.baby.database.CartBean;
import com.xuxin.baby.glide.GlideApp;
import com.xuxin.baby.network.Retrofit;

import org.jetbrains.annotations.NotNull;

/**
 * Created by xu_xin
 * Created on 2020.08.28 0028
 * 我的购物车
 */
public class CartAdapter extends BaseQuickAdapter<CartBean, BaseViewHolder> {

    public CartAdapter() {
        super(R.layout.item_cart);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder holder, CartBean item) {
        RequestOptions options = new RequestOptions().transform(new CenterCrop(), new RoundedCorners(10));
        holder.setText(R.id.item_video_name, item.getTitle());
        holder.setText(R.id.item_video_content, item.getContent());
        holder.setText(R.id.item_video_price, "宝宝币：" + item.getPrice());
        CheckBox item_cart_check = holder.getView(R.id.item_cart_check);
        item_cart_check.setChecked(item.isCheck());
        /**
         * 加载图片
         */
        ImageView item_video_image = holder.getView(R.id.item_video_image);
        String cartImage = Retrofit.image_url + item.getImage();
        LogUtils.e("我的购物车_image = " + cartImage);
        GlideApp.with(getContext()).load(cartImage).placeholder(R.mipmap.img_placeholder260).apply(options).into(item_video_image);
    }
}